<!DOCTYPE html>
<html lang="zh">

<head>
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="expires" content="0">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta id="Version" name="version" content="<%=htmlWebpackPlugin.options.version%>" />
    <link rel="shortcut icon" type="image/x-icon" href="static/logo/favicon.ico" />
    <title>风险工作台</title>
    <script src="./static/project-config.js"></script>
</head>

<body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
    <script>
        // Add dark / light detection that runs before Vue.js load. Borrowed from overreacted.io
        (function () {
            window.__onThemeChange = function () {};

            window.onload = function () {
                if (window.project_config.WEB_DOCKING === 'FSCINDA') {
                    let link = document.querySelector("link[rel*='icon']") || document.createElement(
                        'link');
                    link.type = 'image/x-icon';
                    link.rel = 'shortcut icon';
                    link.href = 'static/logo/project/fscinda/favicon.ico';
                    document.getElementsByTagName('head')[0].appendChild(link);
                } else if (window.project_config.WEB_DOCKING === 'CIBFUND') {
                    let link = document.querySelector("link[rel*='icon']") || document.createElement(
                        'link');
                    link.type = 'image/x-icon';
                    link.rel = 'shortcut icon';
                    link.href = 'static/logo/project/cibfund/favicon.ico';
                    document.getElementsByTagName('head')[0].appendChild(link);
                    // 修改站点标题
                    let title = document.querySelector("title")
                    title.innerText = "风险旁路监测系统"
                }
            }

            function setTheme(newTheme) {
                window.__theme = newTheme;
                preferredTheme = newTheme;
                if (document) {
                    document.body.setAttribute('data-theme', newTheme);
                    // iframe
                    let frameDoms = document.getElementsByTagName("iframe");
                    for (let i = 0; i < frameDoms.length; i++) {
                        if (frameDoms[i].contentDocument && frameDoms[i].contentDocument.body) {
                            frameDoms[i].contentDocument.body.setAttribute('data-theme', newTheme)
                        }
                    }

                    window.__onThemeChange(newTheme);
                }
            }
            let env_config = '<%= JSON.parse(htmlWebpackPlugin.options.env.ENV_CONFIG) %>';
            let web_docking = '<%= JSON.parse(htmlWebpackPlugin.options.env.WEB_DOCKING) %>';
            var docking = env_config === 'project' ? window.project_config.WEB_DOCKING || window.project_config.webDocking : web_docking;
            console.log(env_config, docking, '=======================')
            var preferredTheme;
            try {
                preferredTheme = localStorage.getItem('theme') ;
                console.log(preferredTheme,'preferredTheme')
                if (docking === 'SINOSIG'|| docking === 'CMSCHINA') {
                    preferredTheme = docking;
                } else {
                    preferredTheme = preferredTheme||'blue';
                }
                console.log(preferredTheme,'real-preferredTheme')
            } catch (err) {}

            window.__setPreferredTheme = function (newTheme) {
                setTheme(newTheme);
                try {
                    localStorage.setItem('theme', newTheme);
                } catch (err) {}
            }
            setTheme(preferredTheme);
        })();

    </script>
    <!-- built files will be auto injected -->
    <!--引入 vendor.dll.js -->
    <!-- <script src="./static/vendor.dll.js"></script> -->
    <!-- 全屏幕页面load效果-->
    <div id="custom-loading" style="
            display: flex;
            position:fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            justify-content:center;
            align-items:center;
            background-color:rgba(255,255,255,0.5);
            z-index: 1;">

        <img src="./static/images/loading.gif" alt="loading" style="width: 40px;" />
    </div>
    <script>
        ;
        try {
            if (window.parent === window) {
                document.getElementById('custom-loading').style.display = 'none';
            }
        } catch (e) {};

    </script>
</body>

</html>
